home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-04 / 422mods.zip / JAFO14.422 < prev    next >
Text File  |  1993-03-03  |  12KB  |  407 lines

  1. JAFO14.MOD - The Multiple UL/DL Ratios Mod
  2. JAFO #1 @18868
  3. Sat Feb 27 1993 19:44:28
  4. ┌────────────────────────────────────────────────────────────────────────────┐
  5. │ Mod Name      : JAFO14.MOD               Mod Author: JAFO 1@1     TerraNET │
  6. │ Difficulty    : ██████▒▒▒▒                                1@8857  IceNET   │
  7. │ WWIV Version  : 4.22                                      1@8861  WWIVnet  │
  8. │ Mod Date      : 02/27/93                                  1@18868 WWIVLink │
  9. │ Files Affected: BATCH.C, BBS.C, DIREDIT.C, SR.C, XFER.C, XFERTMP.C,        │
  10. │                 XINIT.C, FCNS.H, VARS.H                                    │
  11. │ Description   : The Multiple UL/DL Ratios Mod                              │
  12. └────────────────────────────────────────────────────────────────────────────┘
  13.  
  14. ══[ Description ]═════════════════════════════════════════════════════════════
  15.  
  16. This modification will enable you to set up different upload/download ratios
  17. for each directory on your system.  You can even give directories a ratio of
  18. 0.000, which would mean they are free.  So if you are using JAFO10, my Free
  19. Download Directories mod, then you should remove it.
  20.  
  21. ══[ Legend ]══════════════════════════════════════════════════════════════════
  22.  
  23.   =  Existing line - Do not change
  24.   +  Add this line
  25.   -  Remove this line
  26.  
  27. ══[ Step 1 ]══════════════════════════════════════════════════════════════════
  28.  
  29. Please back up your source code.  Even the best programmers make mistakes.
  30.  
  31. ══[ Step 2 ]══════════════════════════════════════════════════════════════════
  32.  
  33. In BATCH.C, make the following changes in "void ymbatchdl".
  34.  
  35. =   rr=0;
  36. =   do {
  37. =     tleft(1);
  38. -     if ((syscfg.req_ratio>0.0001) && (ratio()<syscfg.req_ratio))
  39. +     if ((dir_ratios[batch[cur].dir]>0.0001) &&
  40. +         (ratio()<dir_ratios[batch[cur].dir]))
  41. =       rr=1;
  42. =     if (thisuser.exempt & exempt_ratio)
  43. =       rr=0;
  44.  
  45. ══[ Step 3 ]══════════════════════════════════════════════════════════════════
  46.  
  47. In "void make_dl_batch_list", make the following changes.
  48.  
  49. =       if (nsl() < (batch[i].time + at))
  50. =         ok=0;
  51. =       thisk=(batch[i].len+1023)/1024;
  52. -       if ((syscfg.req_ratio>0.0001) && (ratio1(addk+thisk)<syscfg.req_ratio)
  53. -           && (!(thisuser.exempt & exempt_ratio)))
  54. +       if ((dir_ratios[batch[i].dir]>0.0001) &&
  55. +           (ratio1(addk+thisk)<dir_ratios[batch[i].dir]) &&
  56. +           (!(thisuser.exempt & exempt_ratio)))
  57. =         ok=0;
  58. =       if (ok) {
  59.  
  60. ══[ Step 4 ]══════════════════════════════════════════════════════════════════
  61.  
  62. In "void batchdl", make the following change.
  63.  
  64. =       case 'D':
  65. =         if (numbatchdl==0) {
  66. =           nl();
  67. =           pl(get_string(882));
  68. =           nl();
  69. =           break;
  70. =         }
  71. =
  72. =         nl();
  73. -         if (!ratio_ok()) {
  74. +         if (!ratio_ok(max_dirs)) {
  75. =           nl();
  76. =           pl(get_string(883));
  77. =           nl();
  78. =           break;
  79. =         }
  80.  
  81. ══[ Step 5 ]══════════════════════════════════════════════════════════════════
  82.  
  83. In BBS.C, add the following lines to "void dlmainmenu".
  84.  
  85. =       case 'G':
  86. =         helpl=30;
  87. =         temporary_stuff();
  88. =         break;
  89. +       case 'I':
  90. +         nl();
  91. +         npr("The up/download ratio for the current directory is %-5.3f.",
  92. +             dir_ratios[udir[curdir].subnum]);
  93. +         nl();
  94. +         break;
  95. =       case 'L':
  96. =         listfiles();
  97. =         break;
  98.  
  99. ══[ Step 6 ]══════════════════════════════════════════════════════════════════
  100.  
  101. In DIREDIT.C, add the following line in "void modify_dir".
  102.  
  103. = void modify_dir(int n)
  104. = {
  105. =   directoryrec r;
  106. =   char s[81],s1[81],ch,ch2,*ss;
  107. =   int i,i1,done;
  108. +   float f;
  109. =
  110. =   r=directories[n];
  111.  
  112. ══[ Step 7 ]══════════════════════════════════════════════════════════════════
  113.  
  114. Farther down in "void modify_dir", add and change the following lines.
  115.  
  116. =     outstr(get_string(144));
  117. =     pl((r.mask & mask_archive) ? str_yes : str_no);
  118. +     npr("L. Dir Ratio  : %-5.3f\r\n",dir_ratios[n]);
  119. =     nl();
  120. -     prt(2,get_string(119));
  121. -     ch=onek("QABCDEFGHIJK");
  122. +     prt(2,"Which (A-L,Q) ? ");
  123. +     ch=onek("QABCDEFGHIJKL");
  124. =     switch(ch) {
  125.  
  126. ══[ Step 8 ]══════════════════════════════════════════════════════════════════
  127.  
  128. Still farther down in "void modify_dir", add the following lines.
  129.  
  130. =       case 'K':
  131. =         r.mask &= ~mask_archive;
  132. =         nl();
  133. =         prt(5,get_string(158));
  134. =         if (yn())
  135. =           r.mask |= mask_archive;
  136. =         break;
  137. +       case 'L':
  138. +         nl();
  139. +         prt(5,"New ratio? ");
  140. +         input(s,5);
  141. +         f=atof(s);
  142. +         if (s[0]) {
  143. +           dir_ratios[n]=f;
  144. +           save_dir_ratios();
  145. +         }
  146. +         break;
  147. =     }
  148. =   } while ((!done) && (!hangup));
  149. =   directories[n]=r;
  150. = }
  151.  
  152. ══[ Step 9 ]══════════════════════════════════════════════════════════════════
  153.  
  154. In "void insert_dir", add the lines shown.
  155.  
  156. = void insert_dir(int n)
  157. = {
  158. =   directoryrec r;
  159. =   int i,i1,i2,nu;
  160. =   unsigned long *qsc, *qsc_n, m1, m2, m3;
  161. =
  162. =   for (i=num_dirs-1; i>=n; i--) {
  163. =     directories[i+1]=directories[i];
  164. =     dir_dates[i+1]=dir_dates[i];
  165. +     dir_ratios[i+1]=dir_ratios[i];
  166. =   }
  167. =   strcpy(r.name,get_string(159));
  168. =   strcpy(r.filename,get_string(82));
  169. =   strcpy(r.path,syscfg.dloadsdir);
  170. =   r.dsl=10;
  171. =   r.age=0;
  172. =   r.maxfiles=50;
  173. =   r.dar=0;
  174. =   r.type=0;
  175. =   r.mask=0;
  176. =   directories[n]=r;
  177. =   ++num_dirs;
  178. =
  179. +   dir_ratios[n]=syscfg.req_ratio;
  180. +   save_dir_ratios();
  181. +
  182. =   nu=number_userrecs();
  183. =   close_user();
  184.  
  185. ══[ Step 10 ]═════════════════════════════════════════════════════════════════
  186.  
  187. In "void delete_dir", add the lines shown.
  188.  
  189. = void delete_dir(int n)
  190. = {
  191. =   int i,i1,i2,nu;
  192. =   unsigned long *qsc, *qsc_n, m2, m3;
  193. =
  194. =   for (i=n; i<num_dirs; i++) {
  195. =     directories[i]=directories[i+1];
  196. =     dir_dates[i]=dir_dates[i+1];
  197. +     dir_ratios[i]=dir_ratios[i+1];
  198. =   }
  199. =   --num_dirs;
  200. =
  201. +   save_dir_ratios();
  202. +
  203. =   nu=number_userrecs();
  204. =   close_user();
  205.  
  206. ══[ Step 11 ]═════════════════════════════════════════════════════════════════
  207.  
  208. In SR.C, add the following lines in "void send_file".
  209.  
  210. =       case 5:
  211. =         ok=1;
  212. +         if (!dir_ratios[dn]) {
  213. +           nl();
  214. +           pl("You cannot batch download from free directories.");
  215. +           nl();
  216. +           *sent=0;
  217. +           *abort=0;
  218. +           break;
  219. +         }
  220. =         if (numbatch>=MAX_BATCH) {
  221. =           nl();
  222. =           pl(get_string(900));
  223.  
  224. ══[ Step 12 ]═════════════════════════════════════════════════════════════════
  225.  
  226. In XFER.C, change the following lines in "int ratio_ok".
  227.  
  228. - int ratio_ok(void)
  229. + int ratio_ok(int dn)
  230. = {
  231. =   int ok=1;
  232. =   char s[101];
  233. =
  234. =   if (!(thisuser.exempt & exempt_ratio))
  235. -     if ((syscfg.req_ratio>0.0001) && (ratio()<syscfg.req_ratio)) {
  236. +     if ((dir_ratios[dn]>0.0001) && (ratio()<dir_ratios[dn])) {
  237. =       ok=0;
  238. =       nl();
  239. =       nl();
  240. =       sprintf(s,"%s %-5.3f.  %s %-5.3f %s.",
  241. =               get_string(730), ratio(),
  242. -               get_string(731), syscfg.req_ratio,
  243. +               get_string(731), dir_ratios[dn],
  244. =               get_string(732));
  245. =       pl(s);
  246. =       nl();
  247. =     }
  248.  
  249. ══[ Step 13 ]═════════════════════════════════════════════════════════════════
  250.  
  251. Right before "void dliscan1", add the following two functions.
  252.  
  253. void load_dir_ratios(void)
  254. {
  255.   int f,i;
  256.   char s[81];
  257.  
  258.   sprintf(s,"%sRATIOS.DAT",syscfg.datadir);
  259.   f=open(s,O_RDONLY | O_BINARY);
  260.   if (f>0) {
  261.     for (i=0; i<num_dirs; i++)
  262.       read(f,&dir_ratios[i],sizeof(float));
  263.     dir_ratios[max_dirs]=syscfg.req_ratio;
  264.     close(f);
  265.   } else {
  266.     f=open(s,O_RDWR | O_BINARY | O_CREAT, S_IREAD | S_IWRITE);
  267.     if (f>0) {
  268.       for (i=0; i<num_dirs; i++) {
  269.         dir_ratios[i]=syscfg.req_ratio;
  270.         write(f,&dir_ratios[i],sizeof(float));
  271.       }
  272.       dir_ratios[max_dirs]=syscfg.req_ratio;
  273.       close(f);
  274.     }
  275.   }
  276. }
  277.  
  278. void save_dir_ratios(void)
  279. {
  280.   int f,i;
  281.   char s[81];
  282.  
  283.   sprintf(s,"%sRATIOS.DAT",syscfg.datadir);
  284.   f=open(s,O_RDWR | O_BINARY);
  285.   if (f>0) {
  286.     for (i=0; i<num_dirs; i++)
  287.       write(f,&dir_ratios[i],sizeof(float));
  288.     chsize(f,num_dirs*sizeof(float));
  289.     close(f);
  290.   }
  291. }
  292.  
  293. ══[ Step 14 ]═════════════════════════════════════════════════════════════════
  294.  
  295. In "int try_to_download", make the following change.
  296.  
  297. =   ok=1;
  298. =   foundany=1;
  299. =   while ((i>0) && (ok) && (!hangup)) {
  300. -     if (!ratio_ok()) {
  301. +     if (!ratio_ok(dn)) {
  302. =       closedl();
  303. =       return(-1);
  304. =     }
  305. =     tleft(1);
  306.  
  307. ══[ Step 15 ]═════════════════════════════════════════════════════════════════
  308.  
  309. Still in "int try_to_download", add the following lines.
  310.  
  311. =         send_file(s1,&sent,&abort,u.filetype,u.filename,dn, u.numbytes);
  312. =       if (sent) {
  313. -         ++thisuser.downloaded;
  314. -         thisuser.dk += (int) ((u.numbytes+1023)/1024);
  315. +         if (!dir_ratios[dn]) {
  316. +           ++thisuser.downloaded;
  317. +           thisuser.dk += (int) ((u.numbytes+1023)/1024);
  318. +         }
  319. =         ++u.numdloads;
  320. =         SETREC(i);
  321.  
  322. ══[ Step 16 ]═════════════════════════════════════════════════════════════════
  323.  
  324. In XFERTMP.C, change the following line in "void download_temp_arc".
  325.  
  326. = void download_temp_arc(char *fn, int xfer)
  327. = {
  328. =   char s[81],s1[81];
  329. =   long numbytes;
  330. =   double d;
  331. =   int i,f,sent,abort;
  332. =
  333. =   outstr(get_string(847));
  334. =   npr("%s.%s:\r\n\r\n", fn, syscfg.arcs[ARC_NUMBER].extension);
  335. -   if (xfer && !ratio_ok()) {
  336. +   if (xfer && !ratio_ok(max_dirs)) {
  337. =     pl(get_string(848));
  338. =     return;
  339. =   }
  340.  
  341. ══[ Step 17 ]═════════════════════════════════════════════════════════════════
  342.  
  343. In XINIT.C, add the following lines "void init".
  344.  
  345. =   num_dirs=(read(i,directories, (max_dirs*sizeof(directoryrec))))/
  346. =            sizeof(directoryrec);
  347. =   close(i);
  348. =
  349. +   dir_ratios=(float *) mallocx((max_dirs+1)*sizeof(float),"dir_ratios");
  350. +   load_dir_ratios();
  351. +
  352. =   chains=(chainfilerec *) mallocx(50 * sizeof(chainfilerec), "chains");
  353. =   numextrn=0;
  354.  
  355. ══[ Step 18 ]═════════════════════════════════════════════════════════════════
  356.  
  357. In FCNS.H, change the following lines.
  358.  
  359. = void get_arc_cmd(char *out, char *arcfn, int cmd, char *ofn);
  360. = int list_arc_out(char *fn, char *dir);
  361. - int ratio_ok(void);
  362. + int ratio_ok(int dn);
  363. = int dcs(void);
  364. + void load_dir_ratios(void);
  365. + void save_dir_ratios(void);
  366. = void dliscan1(int dn);
  367. = void dliscan_hash(int dn);
  368.  
  369. ══[ Step 19 ]═════════════════════════════════════════════════════════════════
  370.  
  371. In VARS.H, change the following line.
  372.  
  373. = __EXTRN__ unsigned long *qsc, *qsc_n, *qsc_q, *qsc_p;
  374. =
  375. =
  376. - __EXTRN__ float batchtime;
  377. + __EXTRN__ float batchtime, *dir_ratios;
  378. =
  379. = __EXTRN__ double extratimecall, last_time, timeon, time_event, xtime;
  380.  
  381. ══[ Step 20 ]═════════════════════════════════════════════════════════════════
  382.  
  383. Compile your source.  We have changed VARS.H so this means the board will need
  384. a full re-compile.
  385.  
  386. ══[ Step 21 ]═════════════════════════════════════════════════════════════════
  387.  
  388. Load the board and do //DIREDIT.  If you want to create a new free directory,
  389. call it something like "Free Downloads" and give that directory a ratio of
  390. 0.000.  By default, all directories have the ratio assigned in INIT.  If you
  391. wish to change them, do so by selecting 'L' while editing a particular dir
  392. and assign it whatever ratio you like.
  393.  
  394. Also, don't forget to edit your menus to reflect the new 'I' command in
  395. transfers.  This will let users see what the ratio is on a particular dir.
  396.  
  397. ══[ Disclaimer ]══════════════════════════════════════════════════════════════
  398.  
  399. Don't complain to me if your board gets fried, your hard disk goes nuts, or
  400. something terrible happens.  The code in this mod should be harmless, but I
  401. can't guarantee it will work for you.  It works on my board.
  402.  
  403. JAFO 1@1     TerraNET
  404.      1@8857  IceNET
  405.      1@8861  WWIVnet
  406.      1@18868 WWIVLink
  407.